05. CMake and Make
CMake and Make
In the previous notebook, you saw how example code could be split into multiple .h
and .cpp
files, and you used g++
to build all of the files together. For small projects with a handful of files, this works well. But what would happen if there were hundreds, or even thousands, of files in the project? If these files were spread across many directories, it would be difficult to type all of the directory names on the command line each time, and if you wanted to make a small change to just a single file, you probably wouldn't want to recompile every file in the project.
Fortunately, there is a solution to this. Many larger C++ projects use a build system to manage all the files during the build process. The build system allows for large projects to be compiled with a few commands, and build systems are able to do this in an efficient way by only recompiling files that have been changed.
In the notebook below you will learn a little more about what actually happens when you run g++
with multiple files, and we will introduce cmake
(and make
), a build system which is popular in large C++ projects.
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: jupyter
- Opened files (when workspace is loaded): n/a